Skip to content

fix(store): surface FlushFileBuffers failure in journal SYNC mode#335

Merged
singaraiona merged 1 commit into
RayforceDB:devfrom
belowzeroff:fix/journal-windows-flush-check
Jul 18, 2026
Merged

fix(store): surface FlushFileBuffers failure in journal SYNC mode#335
singaraiona merged 1 commit into
RayforceDB:devfrom
belowzeroff:fix/journal-windows-flush-check

Conversation

@belowzeroff

Copy link
Copy Markdown
Contributor

What & why

In RAY_JOURNAL_SYNC mode, ray_journal_write_bytes (src/store/journal.c) is
meant to guarantee each write reaches disk before returning — that is the whole
point of SYNC mode (crash recovery). The POSIX branch enforces this by checking
fsync's return and failing with RAY_ERR_IO; the Windows branch called
FlushFileBuffers but ignored its return. A failed flush was silently
swallowed, so the function returned RAY_OK while the data may not have reached
disk — dropping the durability guarantee the mode exists to provide.

The fix checks FlushFileBuffers (returns 0 / FALSE on failure) and returns
RAY_ERR_IO, mirroring the adjacent fsync check.

Verification & scope

This branch is Windows-only. The project's CI matrix is ubuntu-latest +
macos-latest (no Windows leg), so the changed line is not compiled by CI and
not reproducible locally on macOS. It is a one-line symmetry fix that uses only
symbols already present in the original Windows branch, verified by inspection
against the fsync path two lines above.

No test is added: the flush-failure path is not unit-testable (a successful
FlushFileBuffers / fsync can't be made to fail on demand), which is also why
the equivalent POSIX fsync-failure path is untested. The existing SYNC-mode
write test (test_journal.c, case 4f) still covers the success path. The full
macOS debug (ASan + UBSan) suite builds clean and passes:
3631 of 3632 passed (1 skipped, 0 failed).

Checklist

  • PR targets dev (not master)
  • Commits follow Conventional Commits (fix:)
  • make builds cleanly (no new warnings)
  • make test passes (no unit test added — the Windows-only flush-failure
    path is not testable on demand; see Verification & scope)

In RAY_JOURNAL_SYNC mode ray_journal_write_bytes checks fsync's return on
POSIX and fails the write with RAY_ERR_IO, but the Windows branch ignored
FlushFileBuffers' return. A failed flush there was silently swallowed, so
SYNC mode reported success while the data may not have reached disk —
dropping the durability guarantee the mode exists to provide.

Check FlushFileBuffers (0 = failure) and return RAY_ERR_IO, mirroring the
POSIX path. Windows-only branch (not built on the Linux/macOS CI matrix),
so it is verified by inspection against the adjacent fsync check; the
failure path is not unit-testable, like the existing POSIX one.
@singaraiona
singaraiona merged commit 49d8524 into RayforceDB:dev Jul 18, 2026
9 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants